package com.yanqu.road.server.cmd.activity.clientAct;

import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.useract.UserActModule;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_USER_ACT_DATA_FINISH_GUIDE, desc = "客户端请求记录完成引导")
public class ActivityFinishGuideCmd extends AbstractCommand {

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		PlayerProto.UserActDataFinishGuideReqMsg reqMsg = PlayerProto.UserActDataFinishGuideReqMsg.parseFrom(packet.getBytes());
		eActivityType eActivityType = com.yanqu.road.entity.enums.eActivityType.forValue(reqMsg.getActType());
		if (eActivityType == null) {
			ret = GameErrorCode.E_ACTIVITY_NO_FOUND;
		}
		player.getModule(UserActModule.class).addCompleteGuideActivityType(reqMsg.getActType(), reqMsg.getActSubType());
	}

	@Override
	public void sendData(GamePlayer player) {
		player.sendPacket(Protocol.S_USER_ACT_DATA_FINISH_GUIDE % 20000, PlayerProto.UserActDataFinishGuideRespMsg.newBuilder().setRet(ret));

	}

}
